---
title: Attorney assignment batch
summary: Run the automated attorney assignment batch and process results.
status: draft
owner: SAIF Documentation Generator
last_reviewed: 2026-08-26
library: SAIF.Business.Claim.Legal
reference_type: embedded
operation_id: attorney-assignment-batch
trigger: A scheduled or manual batch run starts the attorney assignment process
---

# Attorney assignment batch

Runs the Oracle-side attorney assignment procedure, resolves results, updates file locations and LCE
records, sends notifications, and syncs Outlook/Exchange calendars.

| Field | Value |
| --- | --- |
| **Operation ID** | attorney-assignment-batch |
| **Trigger** | A scheduled or manual batch run starts the attorney assignment process |
| **Inputs** | Assignment run parameters |
| **Outputs** | Assignment results, notifications, calendar updates |
| **Primary components** | `clsAssignmentProcess.RunAssignmentProcess`, `clsAssignmentProcess.GetAssignmentResults` |
| **Entry point** | `SAIF.Business.Claim.Legal\LegalNet\clsAssignmentProcess.vb` |

## Steps

1. `RunAssignmentProcess()` first calls `GetMaxSeq()`, which executes
   `select pk80005_assignment.max_result_seq from dual` to capture the current
   `MAX(assignment_result_seq_num)` from `assignment_result` as a watermark
   ([pk80005_assignment.max_result_seq](../procedures/pk80005_assignment.md#maxresultseq)) —
   necessary because `run_assignment` writes new rows into the same table and the .NET caller has no
   other way to detect which rows are new. It then invokes `pk80005_ASSIGNMENT.run_assignment` as a
   parameterless stored procedure call (no arguments are passed from the VB.NET side). Internally,
   `run_assignment` is the package's top-level driver: it sequentially runs
   `assign_by_employer`, `assign_dcbs_cases`, `assign_recon_cases`, `assign_rotation_cases`,
   `assign_same`, `assign_health_issue_cases`, `assign_wrkr_conflict_cases`,
   `assign_critical_claim_cases`, `assign_portland_cases`, `assign_remaining_cases`, and
   `previously_assigned` over `PENDA`-status legal cases with unassigned `SET`/`RESET` hearings
   ([pk80005_assignment operations](../procedures/pk80005_assignment.md#operations)). Each of these
   procedures cursors over its candidate cases and calls the shared `assignIt`/`assignItBalanced`
   functions to evaluate a candidate attorney against the package's conflict-of-interest and workload
   rules — employer, adjuster, ALJ, opposing-representation, rotation, calendar, long-leave, location,
   and weekly-caseload checks
   ([BR-PKG2-001](../business-rules.md#br-pkg2-001-employer-conflict-blocks-assignment)
   through
   [BR-PKG2-009](../business-rules.md#br-pkg2-009-weekly-caseload-floor-exempts-low-load-attorneys)).
   Every evaluation is recorded via `insert_results` with a `CA`/`CAC` result code for a completed
   assignment or an `NA*` code identifying the specific blocking reason
   ([BR-PKG2-011](../business-rules.md#br-pkg2-011-successful-assignment-updates-case-status),
   [BR-PKG2-012](../business-rules.md#br-pkg2-012-assignment-result-codes-distinguish-success-from-every-blocking-reason)),
   and `updateSchedule` persists the winning attorney back onto the case's `schedule` row for
   successful assignments. Determining whether a result is `CA` vs. `CAC` (vs. an `NA*` blocking code)
   is therefore performed entirely inside `run_assignment`, not by the VB.NET caller — the .NET side
   only reacts to the result code after the fact
   ([BR-ASG-001](../business-rules.md#br-asg-001-legal-case-evaluation-due-date-is-today-nextworkday-18)).
2. `GetAssignmentResults()` re-reads `MaxSeq` via `GetMaxSeq()` a second time, giving the caller a
   before/after bracket around the `run_assignment` call so `clsAssignmentResults.GetAssignmentResults`
   and `clsAssignmentDetail.GetAssignmentDetail` can filter `pk80005_assignment.get_results` /
   `get_assign_results` to only the rows created since the batch started (via each cursor's `in_num`
   watermark parameter), then loads `clsAssignmentResultCollection` and `clsResultDetailCollection`
   for the `"ASSIGN"` action on the current date.
3. `updateFileLocation()` and `updateLCE()` apply file-location and legal-case-evaluation updates for
   each assignment result, branching by result code
   ([BR-ASG-002](../business-rules.md#br-asg-002-assignment-result-codes-ca-and-cac-trigger)).
4. `SendNotifications()` sends adjuster/attorney e-mail notifications for the batch's results.
5. `updateOutlook("ASSIGN", MaxSeq, "LegalNet")` syncs Outlook/Exchange calendar appointments for
   assigned attorneys; non-production environments redirect these operations to test mailboxes.

## Process flow

The following diagram visualizes this operation's control flow, including the assignment/conflict
logic that executes inside `run_assignment` (subgraph) rather than in the VB.NET caller.

```mermaid
flowchart TD
	Start(["Start assignment<br>batch"]) --> MaxSeq1["GetMaxSeq<br>watermark before"]
	MaxSeq1 --> RunProc

	subgraph RunProc["pk80005_assignment.run_assignment (Oracle)"]
		direction TB
		AssignDrivers["assign_by_employer, assign_dcbs_cases,<br>assign_recon_cases, assign_rotation_cases,<br>assign_same, assign_health_issue_cases,<br>assign_wrkr_conflict_cases,<br>assign_critical_claim_cases,<br>assign_portland_cases,<br>assign_remaining_cases,<br>previously_assigned"] --> AssignIt["assignIt /<br>assignItBalanced:<br>conflict + workload checks"]
		AssignIt --> InsertResults["insert_results:<br>CA/CAC or NA* code"]
		InsertResults --> UpdateSched["updateSchedule<br>(on CA/CAC)"]
	end

	RunProc --> MaxSeq2["GetMaxSeq<br>watermark after"]
	MaxSeq2 --> GetResults["GetAssignmentResults<br>(rows since watermark)"]
	GetResults --> Decision{"Result code?"}
	Decision -->|CA| UpdateFL["updateFileLocation +<br>updateLCE"]
	Decision -->|CAC| UpdateFLConflict["updateFileLocation +<br>updateLCE + conflict<br>notification"]
	Decision -->|NA*| Skip["No downstream<br>update"]
	UpdateFL --> SendNotif["SendNotifications"]
	UpdateFLConflict --> SendNotif
	SendNotif --> UpdateOutlook["updateOutlook ASSIGN"]
	UpdateOutlook --> End(["End"])
```

## Failure and edge-case behavior
- Non-production environments (`GetApplicationEnvironment() <> ApplicationEnvironment.Prod`) redirect
  calendar/mailbox operations to test mailboxes rather than real attorney mailboxes.*

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [Database tables](../database-tables.md)
- [SQL catalog](../sql/index.md)
- [Procedures](../procedures/index.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts.

## Sources
- `SAIF.Business.Claim.Legal\LegalNet\clsAssignmentProcess.vb`
